const app = getApp();
Page({
	data: {
		url: app.globalData.host,
		id: null,
		content: {},
	},
	onLoad: function (options) {
		wx.setNavigationBarTitle({
			title: options.title
		})
		this.setData({
			id: options.id
		})
		this.getList();
	},
	getList(){
		let id = this.data.id;
		wx.showLoading({title: '加载中…'});
		app.request({
			url: '/app/projectCategory/' + id,
			method: 'GET',
			success: res => {
				let content = '';
				if(res.data.description){
					let str = res.data.description;
					let reg1 = new RegExp('<img ','g');
					let reg2 = new RegExp('src="/prod-api','g');
					let newStr = str.replace(reg1,'<img style="max-width:100%;height:auto;display:block;margin:10px 0;"');
					content = newStr.replace(reg2,'src="' + this.data.url);
				}
				this.setData({
					content: content,
					title: res.data.categoryName
				})
			}
		})
		wx.hideLoading();
	}
})
